<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        #box {
            width: 100%;
            height: calc(100vh);
            position: relative;
            background: #009688;
        }

        #drag {
            width: 200px;
            height: 200px;
            position: relative;
            background: #EB7350;
            cursor: move;
        }

        #resize {
            width: 200px;
            height: 200px;
            position: relative;
            background: #f53e08;
            cursor: ew-resize;
        }
    </style>
</head>
<body>
<div id="box">
    <div id="drag"></div>
    <div id="resize"></div>
</div>
<script>
    window.onload = function () {
        var box = document.getElementById('box')
        var drag = document.getElementById('drag')
        var resize = document.getElementById('resize')

        // note_drag(drag);
        drag.onmousedown = function (e) {
            note_drag(e);
        }
        resize.onmousedown = function (e) {
            note_resize(e);
        }

        function note_drag(e) {
            console.log(e)
            let oldX = e.clientX;
            let oldY = e.clientY;


            let oldLeft = e.target.offsetLeft;
            let oldTop = e.target.offsetTop;
            document.onmousemove = (me) => {
                e.target.style.ursor = 'move';
                let newX = me.clientX;
                let newY = me.clientY;

                let moveX = oldX - newX;
                let moveY = oldY - newY;

                let newLeft = oldLeft - moveX;
                let newTop = oldTop - moveY;

                e.target.style.left = `${newLeft}px`;
                e.target.style.top = `${newTop}px`;
            };
            document.onmouseup = () => {
                document.onmousemove = null;
                document.onmouseup = null;
                e.target.style.cursor = '';
            };
            e.preventDefault()
        }

function note_resize(e) {
    let oldX = e.clientX;
    let oldY = e.clientY;

    let oldWidth = e.target.offsetWidth;
    let oldHeight = e.target.offsetHeight;
    document.onmousemove = (me) => {
        let newX = me.clientX;
        let newY = me.clientY;

        let moveX = newX - oldX;
        let moveY = newY - oldY;

        let newWidth = oldWidth + moveX;
        let newHeight = oldHeight + moveY;

        if (newWidth < 180) {
            newWidth = 180;
        }
        if (newHeight < 180) {
            newHeight = 180;
        }

        e.target.style.width = `${newWidth}px`;
        e.target.style.height = `${newHeight}px`;
    };
    document.onmouseup = () => {
        document.onmousemove = null;
        document.onmouseup = null;
    };
    e.preventDefault()
}
    }
</script>

</body>
</html>